package com.zdb.util;

import com.alibaba.dashscope.aigc.generation.GenerationParam;
import com.alibaba.dashscope.aigc.imagesynthesis.ImageSynthesisParam;
import com.alibaba.dashscope.common.Message;
import com.zdb.pojo.LongMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;
import java.util.stream.Collectors;

public class AiLiUtil {
    private static final Logger log = LoggerFactory.getLogger(AiLiUtil.class);


    public static GenerationParam createGenerationParam(List<LongMessage> messages,String model,String apikey,Boolean increment,Boolean thinking){
        List<Message> collect = messages.stream().map(message -> {
            return Message.builder()
                    .content(message.getContent())
                    .role(message.getRole())
                    .build();
        }).collect(Collectors.toList());
        return GenerationParam.builder()
                .apiKey(apikey)
                .model( model)
                .messages(collect)
                .resultFormat(GenerationParam.ResultFormat.MESSAGE)
                .enableThinking(thinking)
                .incrementalOutput( increment)
                .build();
    }
    public static ImageSynthesisParam createImageSynthesisParam( List<LongMessage> messages,String model,String apikey,Boolean increment,Boolean thinking){
        return ImageSynthesisParam.builder()
                .apiKey(apikey)
                .model(model)
                .prompt(messages.get(0).getContent())
                .n(1)
                .size("1024*1024")
                .build();
    }


}
